<?php
class PriceAction extends Action {
    public function __construct() {
        parent::__construct();
    }
    public function index() {
        parent::page();
        $this->tpl->assign('allPrice',$this->model->findAll());
        $this->tpl->display(SMARTY_ADMIN.'price/show.html');
    }
    public function add() {
        if(isset($_POST['send'])) $this->model->add() ? $this->redirect->succ('?a=price','价格区间新增成功!') : $this->redirect->error('系统出错，价格区间新增失败!');
        $this->tpl->display(SMARTY_ADMIN.'price/add.html');
    }
    public function update() {
        if(isset($_GET['id'])) {
            $this->tpl->assign('onePrice',$this->model->findOne());
        }
        if(isset($_POST['send'])) $this->model->update() ? $this->redirect->succ(Tool::getPrevPage(),'价格区间修改成功!') : $this->redirect->error('系统出错，价格区间修改失败!');
        $this->tpl->display(SMARTY_ADMIN.'price/update.html');
    }
    public function delete() {
        if(isset($_GET['id'])) $this->model->delete() ? $this->redirect->succ(Tool::getPrevPage(),'价格区间删除成功!') : $this->redirect->error('系统出错，价格区间删除失败!');
    }
}


?>